
/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:周次煜
 * Date: 2024-03-30
 * Time：20:27
 */


package stack;

public class TestStack {
    public static void main(String[] args) {
        MyStack ms=new MyStack();

        // 入栈
        ms.push(1);
        ms.push(2);
        ms.push(3);
        ms.push(4);
        ms.push(5);


        System.out.println("======出栈元素======");
        // 出栈
        // 先出栈顶
        System.out.println(ms.pop());  // 5
        System.out.println(ms.pop());  // 4
        System.out.println(ms.pop()); // 3



        System.out.println("=======查栈元素==========");
        // 看栈顶
        System.out.println(ms.peek());
        System.out.println(ms.peek());


        System.out.println("========查栈大小========");
        // 栈的大小
        System.out.println(ms.size());

        System.out.println("=======查栈是否为空=======");

        if (ms.isEmpty()) {
            System.out.println("MyStack 为空！");
        } else {
            System.out.println("MyStack 不为空！");
        }

    }
}
